<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SimpleWindow: &lt;tt&gt;sw&lt;/tt&gt;</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SimpleWindow
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title"><code>sw</code> </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md__d_1_2code_2sw_2_r_e_a_d_m_e"></a> <b>中文</b> | English</p>
<p><code>sw</code> 即 <code>SimpleWindow</code>，是一个用于构建 Windows 桌面程序的 C++ GUI 框架，实现了对 Windows 标准控件的面向对象封装，适合用于构建简单的桌面应用程序。</p>
<h1><a class="anchor" id="autotoc_md1"></a>
特点</h1>
<ul>
<li>**基于 Windows API**： <br  />
 SimpleWindow 是一个基于 Windows API 的框架，无其他依赖项。</li>
<li>**支持属性**： <br  />
 实现了类似于 C# 的属性语法，可以直观地获取和修改对象属性。</li>
<li>**高 DPI 支持**： <br  />
 原生支持高 DPI，使用 DIP（设备独立像素）作为默认长度单位。</li>
<li>**灵活的布局**： <br  />
 实现了一套类似于 WPF 的布局系统，支持诸如 <code>GridLayout</code>、<code>StackLayout</code>、<code>DockLayout</code> 等各种布局。</li>
<li>**路由事件**： <br  />
 采用路由事件机制，即事件可以冒泡，从源控件向上传播，可以在不同层次的控件上注册事件处理程序。</li>
</ul>
<h1><a class="anchor" id="autotoc_md2"></a>
快速入门</h1>
<p>以下是一个 SimpleWindow 的 HelloWorld 程序，更多示例详见<a href="./examples">这里</a>。</p>
<div class="fragment"><div class="line"> ++</div>
<div class="line"><span class="preprocessor">#include &quot;SimpleWindow.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, INT nCmdShow)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// 窗口对象</span></div>
<div class="line">    <a class="code hl_class" href="classsw_1_1_window.html">sw::Window</a> mainWindow;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// 按钮对象</span></div>
<div class="line">    <a class="code hl_class" href="classsw_1_1_button.html">sw::Button</a> button;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// 修改窗口的布局方式，让按钮居中</span></div>
<div class="line">    mainWindow.<a class="code hl_function" href="classsw_1_1_window.html#abdf47e48c8a4e9d9c368cb549ba3d938">SetLayout</a>&lt;<a class="code hl_class" href="classsw_1_1_fill_layout.html">sw::FillLayout</a>&gt;();</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// 对Text属性赋值即可修改按钮文本</span></div>
<div class="line">    button.<a class="code hl_variable" href="classsw_1_1_wnd_base.html#a9afff86d32e9b54cccc204ef29a85891">Text</a> = L<span class="stringliteral">&quot;Click Me&quot;</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// 注册按钮单击事件处理函数，实现单击按钮弹出消息框</span></div>
<div class="line">    button.<a class="code hl_function" href="classsw_1_1_u_i_element.html#a62c0e59790735abb3f0a9f002e651c16">RegisterRoutedEvent</a>(sw::ButtonBase_Clicked,</div>
<div class="line">        [&amp;](<a class="code hl_class" href="classsw_1_1_u_i_element.html">sw::UIElement</a>&amp; sender, <a class="code hl_struct" href="structsw_1_1_routed_event_args.html">sw::RoutedEventArgs</a>&amp; e) {</div>
<div class="line">            sw::MsgBox::Show(mainWindow, L<span class="stringliteral">&quot;Hello, SimpleWindow!&quot;</span>);</div>
<div class="line">        });</div>
<div class="line"> </div>
<div class="line">    mainWindow.<a class="code hl_function" href="classsw_1_1_u_i_element.html#a32893339be348aa964441954f3a31101">AddChild</a>(button);</div>
<div class="line">    mainWindow.<a class="code hl_function" href="classsw_1_1_window.html#a3281c944ffc505243ff2b958b42e6fa7">Show</a>();</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// 开始消息循环</span></div>
<div class="line">    <span class="keywordflow">return</span> <a class="code hl_function" href="classsw_1_1_app.html#a05192f9abf49cc0a698024855dde22de">sw::App::MsgLoop</a>();</div>
<div class="line">}</div>
<div class="ttc" id="aclasssw_1_1_app_html_a05192f9abf49cc0a698024855dde22de"><div class="ttname"><a href="classsw_1_1_app.html#a05192f9abf49cc0a698024855dde22de">sw::App::MsgLoop</a></div><div class="ttdeci">static int MsgLoop()</div><div class="ttdoc">消息循环</div></div>
<div class="ttc" id="aclasssw_1_1_button_html"><div class="ttname"><a href="classsw_1_1_button.html">sw::Button</a></div><div class="ttdoc">按钮</div><div class="ttdef"><b>Definition</b> Button.h:11</div></div>
<div class="ttc" id="aclasssw_1_1_fill_layout_html"><div class="ttname"><a href="classsw_1_1_fill_layout.html">sw::FillLayout</a></div><div class="ttdoc">一种将全部元素都铺满的布局，一般用于在只有一个子元素的时候将该元素铺满整个可用区域</div><div class="ttdef"><b>Definition</b> FillLayout.h:11</div></div>
<div class="ttc" id="aclasssw_1_1_u_i_element_html"><div class="ttname"><a href="classsw_1_1_u_i_element.html">sw::UIElement</a></div><div class="ttdoc">表示界面中的元素</div><div class="ttdef"><b>Definition</b> UIElement.h:24</div></div>
<div class="ttc" id="aclasssw_1_1_u_i_element_html_a32893339be348aa964441954f3a31101"><div class="ttname"><a href="classsw_1_1_u_i_element.html#a32893339be348aa964441954f3a31101">sw::UIElement::AddChild</a></div><div class="ttdeci">bool AddChild(UIElement *element)</div><div class="ttdoc">添加子控件</div></div>
<div class="ttc" id="aclasssw_1_1_u_i_element_html_a62c0e59790735abb3f0a9f002e651c16"><div class="ttname"><a href="classsw_1_1_u_i_element.html#a62c0e59790735abb3f0a9f002e651c16">sw::UIElement::RegisterRoutedEvent</a></div><div class="ttdeci">void RegisterRoutedEvent(RoutedEventType eventType, const RoutedEvent &amp;handler)</div><div class="ttdoc">注册路由事件处理函数，当事件已注册时会覆盖已注册的函数</div></div>
<div class="ttc" id="aclasssw_1_1_window_html"><div class="ttname"><a href="classsw_1_1_window.html">sw::Window</a></div><div class="ttdoc">窗口</div><div class="ttdef"><b>Definition</b> Window.h:34</div></div>
<div class="ttc" id="aclasssw_1_1_window_html_a3281c944ffc505243ff2b958b42e6fa7"><div class="ttname"><a href="classsw_1_1_window.html#a3281c944ffc505243ff2b958b42e6fa7">sw::Window::Show</a></div><div class="ttdeci">void Show()</div><div class="ttdoc">显示窗口</div></div>
<div class="ttc" id="aclasssw_1_1_window_html_abdf47e48c8a4e9d9c368cb549ba3d938"><div class="ttname"><a href="classsw_1_1_window.html#abdf47e48c8a4e9d9c368cb549ba3d938">sw::Window::SetLayout</a></div><div class="ttdeci">void SetLayout()</div><div class="ttdoc">设置窗口的默认布局方式</div><div class="ttdef"><b>Definition</b> Window.h:252</div></div>
<div class="ttc" id="aclasssw_1_1_wnd_base_html_a9afff86d32e9b54cccc204ef29a85891"><div class="ttname"><a href="classsw_1_1_wnd_base.html#a9afff86d32e9b54cccc204ef29a85891">sw::WndBase::Text</a></div><div class="ttdeci">const Property&lt; std::wstring &gt; Text</div><div class="ttdoc">窗口标题或控件文本</div><div class="ttdef"><b>Definition</b> WndBase.h:158</div></div>
<div class="ttc" id="astructsw_1_1_routed_event_args_html"><div class="ttname"><a href="structsw_1_1_routed_event_args.html">sw::RoutedEventArgs</a></div><div class="ttdoc">路由事件的参数</div><div class="ttdef"><b>Definition</b> RoutedEvent.h:133</div></div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md3"></a>
开发文档</h1>
<p>有关 SimpleWindow 的详细开发文档，请访问 <a href="https://mzying2001.github.io/sw">mzying2001.github.io/sw</a>。</p>
<h1><a class="anchor" id="autotoc_md4"></a>
许可证</h1>
<p>SimpleWindow 框架是基于 MIT 许可证发布的，允许您在自己的项目中自由使用和修改它。</p>
<h1><a class="anchor" id="autotoc_md5"></a>
贡献</h1>
<p>欢迎贡献者参与 SimpleWindow 的开发和改进。如果您发现 Bug 或有改进建议，请提出 Issue 或发送 Pull Request。</p>
<h1><a class="anchor" id="autotoc_md6"></a>
Star 趋势</h1>
<p><a href="https://starchart.cc/Mzying2001/sw"><img src="https://starchart.cc/Mzying2001/sw.svg" alt="Stargazers over time" style="pointer-events: none;" class="inline"/></a> </p>
</div></div><!-- PageDoc -->
<a href="doxygen_crawl.html"/>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">制作者 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0 </li>
  </ul>
</div>
</body>
</html>
